﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Data;
using System.Data.SQLite;
using System.Data;

namespace Data
{
    public class BuscarPersonalDataAccess
    {
        private SQLiteConnection con = DataBaseHelper.GetConnection("BDHostal.sqlite");
        DataSet dataSet = new DataSet();
        DataTable dt = new DataTable();
        public DataTable buscarDatos(string persona)
        {
            string cmd = "SELECT numeroDocumento,nombre,apellido FROM datosPersonal WHERE nombre like '%" + persona.ToLowerInvariant() + "%' OR apellido like '%" + persona.ToLowerInvariant() + "%'";
            {
                try
                {
                    con.Open();
                    SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter(cmd, con);
                    dataSet.Reset();
                    dataAdapter.Fill(dataSet);
                    dt = dataSet.Tables[0];        
                }
                catch (SystemException ex)
                {
                }
                finally
                {
                    con.Close();
                }
            }
            return dt;
        }
    }
}
